package edu.washington.ling.syntric.io;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class TreeRepresentation {
	private String layer;
	private Set<String> metaData;
	private String format;
	private String[] lines;
	
	public TreeRepresentation(String layer) {
		this.layer = layer;
		this.metaData = new HashSet<String>();
		this.format = null;
		this.lines = new String[0];
	}
	public TreeRepresentation(List<String> lines, String layer) {
		this.layer = layer;
		this.metaData = new HashSet<String>();
		this.format = null;
		this.lines = lines.toArray(new String[lines.size()]);
	}
	public TreeRepresentation(String[] lines, String layer) {
		this.layer = layer;
		this.metaData = new HashSet<String>();
		this.format = null;
		this.lines = lines;
	}
	public TreeRepresentation(List<String> lines, String layer, String format) {
		this.layer = layer;
		this.metaData = new HashSet<String>();
		this.format = format;
		this.lines = lines.toArray(new String[lines.size()]);
	}
	public TreeRepresentation(String[] lines, String layer, String format) {
		this.layer = layer;
		this.metaData = new HashSet<String>();
		this.format = format;
		this.lines = lines;
	}
	public String[] getTreeLines(){
		return lines;
	}
	public String getLayer() {
		return layer;
	}
	public void setMetaData(String[] metaDataArr) {
		for (int i = 0; i < metaDataArr.length; i++) {
			metaData.add(metaDataArr[i]);
		}
	}
	public void setMetaData(Set<String> metaData) {
		this.metaData = metaData;
	}
	public void addMetaData(String label) {
		metaData.add(label);
	}
	public Set<String> getMetaData() {
		return metaData;
	}
	public boolean hasMetaData(String label) {
		return metaData.contains(label);
	}
	public void setFormat(String format) {
		this.format = format;
	}
	public boolean hasFormat() {
		return format != null;
	}
	public String getFormat() {
		return format;
	}
	public void setTreeLines(String[] lines) { 
		this.lines = lines;
	}
	public void setTreeLines(List<String> lines) {
		this.lines = lines.toArray(new String[lines.size()]);
	}
	public boolean hasTreeLines() {
		return this.lines != null;
	}
}
